<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>rxgitcid demo</title>
  <script src="https://cdn.jsdelivr.net/npm/rxcornor@0.0.8/dist/index.js" id="rxcornor"
    link="https://github.com/cheere/rxgitcid" target="_blank"></script>

  <!-- 用于加载 README.md -->
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/marked@4.0.0/marked.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/styles/default.min.css">
  <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/highlight.min.js"></script>
</head>

<body>
  <h1>rxgitcid</h1>
  <p>Get the commit <b>ID</b> of the last commit of git.</p>
  <br>
  <hr>
  <div id='content'></div>

  <!-- 加载 md -->
  <script type="text/javascript">
    $(function () {
      $.ajax({
        url: 'README.md',
        dataType: 'text',
        success: function (data) {
          document.getElementById('content').innerHTML = marked.parse(data)
          addColor()
        }
      });
    });
  </script>

  <script>
    marked.setOptions({
      renderer: new marked.Renderer(),
      gfm: true,
      tables: true,
      breaks: false,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false,
      highlight: function (code, lang) {
        //使用 highlight 插件解析文档中代码部分
        return hljs.highlightAuto(code, [lang]).value;
      }
    });
  </script>
  <script>
    function addColor() {
      setTimeout(() => {
        preCodeTohljs()
      }, 200);
    }

    function preCodeTohljs() {
      const code = $('pre').find('code')
      code.each(function () {
        $(this).addClass('hljs')
      })
    }
  </script>
</body>

</html>